﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyTruongHoc_App
{

    public partial class AddEditText : Form
    {
        public delegate void EventUpdate(object sender);
        public event EventUpdate Finished, Cancel;

        private Boolean editMode = false;
        private int editId = 0;

        public AddEditText()
        {
            InitializeComponent();
        }

        private void bt_ok_Click(object sender, EventArgs e)
        {
            try
            {
                Finished(this);
                this.Close();
            }
            catch { }
        }

        private void AddEditText_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                Cancel(this);
            }
            catch { }
        }

        public String EditText
        {
            get { return tb_text.Text; }
            set { tb_text.Text = value; }
        }

        public Boolean EditMode
        {
            get { return editMode; }
            set { editMode = value; }
        }

        public int EditId
        {
            get { return editId; }
            set { editId = value; }
        }

        private void tb_text_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                bt_ok_Click(bt_ok, new EventArgs());
        }
    }
}
